#include <REGX52.H>

void DelayMs(unsigned int ms) //@11.0592MHz
{
    unsigned char i, j;
    while(ms){
        i = 2;
        j = 259; 
        do {
            while (--j);
        } while (--i);
        ms--;
    }
}

void main() {
	unsigned char ledNum = 0;
	while(1) {
		if (P3_1 == 0) {
			DelayMs(20);
			while (P3_1 == 0);
			DelayMs(20);
			ledNum++;       // 实现二进制加一点灯
			P2 = ~ledNum;   // 低电平点亮
		}
	}
}
